// run: $exec < input
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

std::vector<std::pair<int, int> > v;
std::vector<std::pair<int, int> > ans;
int const maxn = 100007;
int degree[maxn];
int n, k;

std::pair<int, int> get_range(int start, int x)
{
	std::pair<int, int> tmp(start, start);
	int i = start;
	for (; i < n; i++)
		if (v[i].first != x) break;
	tmp.second = i - 1;
	return tmp;
}

int main()
{
	std::cin >> n >> k;
	v.resize(n);
	for (int i = 0; i < n; i++) {
		std::cin >> v[i].first;
		v[i].second = i + 1;
	}
	std::sort(v.begin(), v.end());

	std::pair<int,int> last = get_range(0, 0);
	if (last.second != last.first) { std::cout << "-1\n"; return 0; }

	int next = 1;
	for (; last.second < n - 1; next++) {
		std::pair<int,int> tmp = get_range(last.second + 1, next);
		if (tmp.second < tmp.first) { std::cout << "-1\n"; return 0; }
		int t = last.first;
		for (int i = tmp.first; i <= tmp.second; i++) {
			ans.push_back(std::make_pair(v[i].second, v[t].second));
			degree[v[i].second]++;
			degree[v[t++].second]++;
			if (t > last.second) t = last.first;
		}

		last = tmp;
	}

	for (int i = 1; i <= n; i++)
		if (degree[i] > k) { std::cout << "-1\n"; return 0; }

	std::cout << ans.size() << '\n';
	for (int i = 0; i < (int)ans.size(); i++)
		std::cout << ans[i].first << ' ' << ans[i].second << '\n';
}

